package com.softlab.retailwholesalesystem.controller;

import com.softlab.retailwholesalesystem.entity.VO.RepositoryGoodsVOEntity;
import com.softlab.retailwholesalesystem.entity.StoreEntity;
import com.softlab.retailwholesalesystem.service.IStoreService;
import com.softlab.retailwholesalesystem.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class StoreController extends BaseController{

    @Autowired
    IStoreService service;

    @RequestMapping("/store")
    public JsonResult<List<RepositoryGoodsVOEntity>> getAllStore() {
        List<RepositoryGoodsVOEntity> store = service.getAllStore();
        return new JsonResult<>(200,"库存列表查询成功",store);
    }

    @RequestMapping("/store/add")
    public JsonResult<Void> addStore(StoreEntity store){
        service.addStore(store);
        return new JsonResult<>(200,"库存添加成功");
    }

    @RequestMapping("/store/delete")
    public JsonResult<Void> deleteStore(StoreEntity store){
        service.deleteStore(store);
        return new JsonResult<>(200,"库存删除成功");
    }

    @RequestMapping("/store/update")
    public JsonResult<Void> changeStore(StoreEntity store){
        service.changeStore(store);
        return new JsonResult<>(200,"库存修改成功");
    }


    @RequestMapping("/store/search")
    public JsonResult<List<RepositoryGoodsVOEntity>> getStores(StoreEntity store){
        List<RepositoryGoodsVOEntity> se = service.getStores(store);
        return new JsonResult<>(200,"所有相关库存获取成功", se);
    }
}
